<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>折叠面板</title>
  <style>
    .container {
      border-radius: 20px;
      height: 300px;
      width: 200px;
      border: 2px solid lightseagreen;
      overflow: hidden;
      transition: height .5s;
    }
    .height-auto {
      height: 500px;
    }
  </style>
</head>
<body>

<div class="container">
  <p>第一行</p>
  <p>第二行</p>
  <p>第二行</p>
  <p>第二行</p>
  <p>第二行</p>
  <p>第二行</p>
  <p>第二行</p>
  <p>第二行</p>
  <p>第二行</p>
  <p>第二行</p>
  <p>第二行</p>
  <p>第二行</p>
</div>


<script>
  const $container = document.querySelector('.container');
  $container.addEventListener('click', function() {
    const classList = Array.from(this.classList);
    if (classList.includes('height-auto')) {
      this.classList.remove('height-auto');
    } else {
      this.classList.add('height-auto')
    }
  })
</script>
</body>
</html>
